/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/9/4
 * Time: 22:14
 */
public class Solution {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int len = timeSeries.length;
        if (len == 1) return duration;
        int totalDuration = 0;
        for (int i = 0; i < len - 1; i++) {
            int x = timeSeries[i + 1] -  timeSeries[i];
            totalDuration += Math.min(x, duration);
        }
        //加上最后一次的持续时间
        return totalDuration + duration;
    }
    public static void main(String[] args) {
        Solution solution = new Solution();
        int poisonedDuration = solution.findPoisonedDuration(new int[]{1,2,3}, 2);
        System.out.println(poisonedDuration);
    }
}